﻿#region Copyright © 2009 by Bj Rollison
/// <copyright> Copyright © 2009 by Bj Rollison
/// This source is subject to the Microsoft Public License (Ms-PL).
/// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
/// All other rights reserved.
/// </copyright>
#endregion

namespace TestingMentor.StatisticalSampleSizeCalculator
{
  using System;
  using System.Windows.Forms;

  /// <summary>
  /// HelperClass contains static helper methods used by form class
  /// </summary>
  internal class HelperClass
  {
    #region PRIVATE CONSTRUCTOR
    /// <summary>
    /// Prevents a default instance of the HelperClass class from being created.
    /// </summary>
    private HelperClass() { }
    #endregion PRIVATE CONSTRUCTOR

    #region INTERNAL METHODS
    /// <summary>
    /// Displays an common input error dialog box
    /// </summary>
    /// <param name="msg">Appropriate error message</param>
    internal static void ShowMsgBox(string msg)
    {
      MessageBox.Show(
        msg,
        Properties.Resources.InputErrorTitle,
        MessageBoxButtons.OK,
        MessageBoxIcon.Error,
        MessageBoxDefaultButton.Button1,
        MessageBoxOptions.RightAlign);
    }

    /// <summary>
    /// Validates the input is a type double
    /// </summary>
    /// <param name="value">string representing the input value</param>
    /// <param name="result">A type double returned to the caller</param>
    /// <returns>True if value is a double; otherwise false.</returns>
    internal static bool IsNumber(string value, out double result)
    {
      bool isNumber = false;
      if (double.TryParse(value, out result))
      {
        isNumber = true;
      }

      return isNumber;
    }
    #endregion INTERNAL METHODS
  }
}
